package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.JobDetailedListMaintain;
import com.ruoyi.system.mapper.JobDetailedListMaintainMapper;
import com.ruoyi.system.service.JobDetailedListMaintainService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 风险作业分级清单维护(JobDetailedListMaintain)表服务实现类
 *
 * @author makejava
 * @since 2022-11-23 09:20:06
 */
@Service("jobDetailedListMaintainService")
public class JobDetailedListMaintainServiceImpl implements JobDetailedListMaintainService {
    @Resource
    private JobDetailedListMaintainMapper jobDetailedListMaintainDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public JobDetailedListMaintain queryById(Integer id) {
        return this.jobDetailedListMaintainDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param jobDetailedListMaintain 筛选条件
     * @param pageRequest             分页对象
     * @return 查询结果
     */
    @Override
    public Page<JobDetailedListMaintain> queryByPage(JobDetailedListMaintain jobDetailedListMaintain, PageRequest pageRequest) {
        long total = this.jobDetailedListMaintainDao.count(jobDetailedListMaintain);
        return new PageImpl<>(this.jobDetailedListMaintainDao.queryAllByLimit(jobDetailedListMaintain, pageRequest), pageRequest, total);
    }

    @Override
    public List<JobDetailedListMaintain> queryAll(JobDetailedListMaintain jobDetailedListMaintain) {
        return jobDetailedListMaintainDao.queryAll(jobDetailedListMaintain);
    }

    /**
     * 新增数据
     *
     * @param jobDetailedListMaintain 实例对象
     * @return 实例对象
     */
    @Override
    public JobDetailedListMaintain insert(JobDetailedListMaintain jobDetailedListMaintain) {
        this.jobDetailedListMaintainDao.insert(jobDetailedListMaintain);
        return jobDetailedListMaintain;
    }

    /**
     * 修改数据
     *
     * @param jobDetailedListMaintain 实例对象
     * @return 实例对象
     */
    @Override
    public JobDetailedListMaintain update(JobDetailedListMaintain jobDetailedListMaintain) {
        this.jobDetailedListMaintainDao.update(jobDetailedListMaintain);
        return this.queryById(jobDetailedListMaintain.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.jobDetailedListMaintainDao.deleteById(id) > 0;
    }
}
